package com.example.demo.common.config;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.example.demo.common.exception.DataValidException;
import com.example.demo.common.utils.Response;

@RestControllerAdvice
public class GlobalExceptionConfig {

	@ExceptionHandler(DataValidException.class)
	public Response handlerDataValidException(
			DataValidException ex) {
		return Response.error(10001, 
				"非法数据！", ex.getMessage());
	}
	
	@ExceptionHandler(Exception.class)
	public Response handlerException(
			Exception ex) {
		return Response.error(50001, 
				"服务器内部错误！", ex.getMessage());
	}
}




